﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using xTeam.Glgcx.CommonUtilities;

namespace xTeam.Glgcx.Controllers.HomePage
{
    public class ArchiveController : BaseController
    {
        //
        // GET: /Archive/

        public ActionResult Index(string eTag = "")
        {
            return RedirectToAction("List", new { eTag = eTag });
        }

        public ActionResult List(string eTag = "")
        {
            int pageSize = 20;
            var articleList = _archiveBal.GetArchiveListByClassifyETag(eTag, pageSize, ETagType.PinYin);
            ViewData.Model = articleList;
            return View();
        }

        public ActionResult Preview(int id = 0)
        {
            var viewModel = new ArchiveViewModel();
            var archive = _archiveBal.GetArchiveById(id, true);
            if (archive == null)
                throw new HttpException(404, "文件没有找到");
            viewModel.Archive = archive;
            ViewData.Model = viewModel;
            return View();
        }
        public ActionResult Article(string tagName = "")
        {
            var viewModel = new ArchiveViewModel();
            var archive = _archiveBal.GetArchiveByETag(tagName);
            if (archive == null)
                throw new HttpException(404, "文件没有找到");
            viewModel.Archive = archive;
            viewModel.ImageRoot = _imageRoot;
            ViewData.Model = viewModel;
            return View("Preview");
        }

        public ActionResult RelatePart(string eTag = "", int pageSize = 5)
        {
            var articleList = _archiveBal.GetArchiveListByClassifyETag(eTag, pageSize);
            ViewData.Model = articleList;
            return View();

        }

        public ActionResult HomePart(string eTag = "", int pageSize = 5)
        {
            ViewData.Model = _archiveBal.GetArchiveListByClassifyETag(eTag, pageSize);
            return View();
        }

        public ActionResult SysBrand(string eTag = "", int pageSize = 5)
        {
            ViewData.Model = _archiveBal.GetArchiveListByClassifyETag(eTag, pageSize);
            return View();
        }

        public ActionResult ImagePart(string eTag = "", int pageSize = 5)
        {
            var articleList = _archiveBal.GetArchiveListByClassifyETag(eTag, pageSize, 1);
            articleList.ImageRoot = _imageRoot;
            ViewData.Model = articleList;

            return View();
        }
        public ActionResult ImagePart2(string eTag = "", int pageSize = 5)
        {
            var articleList = _archiveBal.GetArchiveListByClassifyETag(eTag, pageSize, 1);
            articleList.ImageRoot = _imageRoot;
            ViewData.Model = articleList;

            return View();
        }

    }
}
